<?php
/**
 * 功能: 问题意见反馈
 * User: 文丹
 * Date: 2018/7/23 0023
 * Time: 9:34
 */

namespace app\index\controller;

use think\Controller;
use think\Db;

class Problem extends Controller{
    /**
     * 问题意见反馈
     */
    public function feedback(){
        $token = trim(input('token'));
        if(empty($token)){
            return json(['msg'=>'token不能为空','ok'=>false]);
        }
        $user    = model('User')->getUser($token);
        $phone   = trim(input('phone'));
        $content = trim(input('content'));
        if(empty($content)){
            return json(['msg'=>'反馈的内容不能为空','ok'=>false]);
        }
        $data = [
            'user_id'=>$user['id'],
            'phone'=>$phone,
            'content'=>$content,
            'time'=>time(),
        ];
        $result = model('Problem')->feedback($data);
        if($result){
            return json(['msg'=>'反馈成功','ok'=>true]);
        }else{
            return json(['msg'=>'反馈失败，请稍后再试','ok'=>false]);
        }

    }


}